<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>
<%@ taglib prefix ="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<%@ include file="/common/common-css.jsp"%>
		
		<link rel="stylesheet" href="/loan_manager/css/common-loading.css">
		
		<style>
			#jquery-table td {
				cursor: pointer !important
			}
			
			.productthumbnail {
				width: 100px;
				height: 100px;
			}
			
			@media (min-width: 768px) and (max-width: 1200px) {
				.backup-text {
					width: 100px !important;
				}
			}
		</style>
	</head>
	<body  class="no-skin">
		<%@ include file="/common/common-loading.jsp"%>
		<div class="page-content">
			<div class="page-header" style="margin-bottom:0px;padding-bottom:10px;">
				<h1 id="fu_name">
				</h1>
			</div>
			<form id="queryForm" method="post">
				<div class="page-content-area"> 
				<div class="row">
  					<div class="col-sm-12">
						<div class="widget-box" style="border:0px solid #ccc; border-top:none;border-bottom:none;margin-top:15px;">
							<hr style="margin-top:0px;margin-bottom:0x">
							  <div class="form-group col-xs-12 col-sm-4 "> 
												<label class="col-sm-2 control-label"  style="text-align:right"  for="sex">时间:</label>
												<div class="col-sm-6">
													<div class="input-daterange input-group col-sm-12">
														<input type="text" data-date-format="yyyy-mm-dd" class="fromDate date-picker input-sm form-control" style="padding-left:0px" name="startTime">
														<span class="input-group-addon" style="width:6px">
															<i class="fa fa-exchange"></i>
														</span>
														<input type="text" data-date-format="yyyy-mm-dd" class="endDate date-picker input-sm form-control" style="padding-left:0px" name="endTime">
													</div>
												</div>
											</div>
							<div class=" widget-body">
								<div class="widget-main" >
								
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right" >平台:</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-6">
														<select name="platfrom">
															<option value="">全部</option>
															<option value="android">安卓</option>
															<option value="ios">ios</option>
														</select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">产品：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="product" name="product" list="%{paramsMap.productList}" listKey="product_id" listValue="product_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">渠道：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="channel" name="channel" list="%{paramsMap.channelList}" listKey="channel_id" listValue="channel_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div>
											
											<%-- <div class="form-group col-xs-12 col-sm-4">
												<label class="col-sm-2 control-label"  style="text-align:right">活动类型：</label>
												 <div class="col-sm-4">
													<div class="input-daterange input-group col-sm-12">
															<s:select id="activityType" name="activityType" list="%{paramsMap.activityTypeList}" listKey="activity_type_id" listValue="activity_type_name" 
															headerKey="" headerValue="全部" cssClass="form-control"></s:select>
													</div>
												</div>
											</div> --%>
											
											<div class="form-group col-xs-12 col-sm-4 col-md-3 col-lg-3">
											<label class="col-sm-4 control-label"
												style="text-align: right" for="activity_id">活动id:</label>
											<div class="col-sm-8" style="padding-left: 0;">
												<input type="text" style="padding-left: 0px" name="activity_id"
													id="activity_id">
											</div>
										</div>
		
									</div><!-- /.widget-main -->
								</div><!-- /.widget-body -->
						</div><!-- /.widget-box -->
					</div><!-- /.col-sm-12 -->
					
					<div class="col-md-12 center">
						<div class="clearfix form-actions">
				
							<button class="btn btn-purple  no-border" type="button" name="btn-query" onclick="query_any()" id="btn-query" > 
								<i class="ace-icon fa fa-search icon-on-right bigger-110"></i> 
								查询 
							</button> 
							&nbsp;&nbsp;&nbsp;
							 <button class="btn btn-purple no-border" type="button" name="btn-query" id="instantStatistics">
                            	<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
                            	刷新实时数据
                        	</button>
							&nbsp;&nbsp;&nbsp;
							<button class="btn btn-grey  no-border" type="reset">
								<i class="ace-icon fa fa-undo icon-on-right bigger-110"></i>
								重置
							</button>
							
				 		 </div>
		  			 </div>
				
				</div><!-- /.row -->
				
				<div class="row">
					<div class="col-xs-12">
						<a href="javascript:void(0)" class="btn btn-success btn-small"
							id="output" onclick="loadlist()">导出列表</a>
						<table id="jquery-table"
							class="table table-striped table-bordered table-hover">
						</table>
					</div>
				</div>
									 
				<hr style="display:none;" id="delete_hr">
					<div class="row">
					<div class="col-xs-12">
						<table id="jquery-table" class="table table-striped table-bordered table-hover">
						</table>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div><!-- /.page-content-area -->
			</form>
		</div>
	</body>
</html>

<%@ include file="/common/common-js.jsp" %>
<!-- loading js -->
<script type="text/javascript" src="${ctx}/js/common-loading.js"></script>
<script type="text/javascript" src="${ctx}/js/call_func.js"></script>
<link rel="stylesheet" href="${ctx}/ace/css/just-tip.css"/>
<script src="${ctx}/ace/js/justTools.js"></script>

<!-- inline scripts related to this page -->
<script type="text/javascript">

function loadlist() {
	var form = document.forms["queryForm"];
	form.action = ctx + "/collaborate/exportRegisterData.action";
	form.submit();
}
		
    //【查询】按钮Click事件
	function query_any(){
	 	$("#output").removeAttr("style");
		if(jqTable != null){
			jqTable.fnDraw();
		} else {
			loaddata();
		}
		 $("#delete_btn").attr("style","display:block");
		 $("#delete_hr").attr("style","margin-top:0px;margin-bottom:20px;display:block");
	 };
	
	 var jqTable = null;
	 var loaddata = function(){
		jQuery(function($) {
			jqTable = $('#jquery-table').dataTable( {
			    //数据列控制（包括对应返回JSON属性名称，对应表头列索引位置、数据转换封装等）
			    "columnDefs": [
					{	  
						  "title":'日期',
						  "name":"cdate",
						  "data": "cdate",
						  "targets": [0],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
					},
					{	  
						  "title":'产品',
						  "name":"prd_name",
						  "data": "prd_name",
						  "targets": [1],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
					},
					{	  
						  "title":'渠道',
						  "name":"channel_name",
						  "data": "channel_name",
						  "targets": [2],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%",
					},
					{	  
						  "title":'平台',
						  "name":"platform",
						  "data": "platform",
						  "targets": [3],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%"
					},
					/* 
					{	  
						  "title":'活动类型',
						  "name":"activity_type_name",
						  "data": "activity_type_name",
						  "targets": [4],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%"
					}, */
					{	  
						  "title":'活动ID',
						  "name":"activity_id",
						  "data": "activity_id",
						  "targets": [4],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%"
					},
					/*  {	  
						  "title":'H5-登记人数',
						  "name":"external_register_count",
						  "data": "external_register_count",
						  "targets": [4],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%"
					}, */
					{	  
						  "title":'注册人数1',
						  "name":"external_new_register_count",
						  "data": "external_new_register_count",
						  "targets": [5],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%"
					}, 
					{	  
						  "title":'注册人数2',
						  "name":"app_activate_count",
						  "data": "app_activate_count",
						  "targets": [6],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%"
					},
					{	  
						  "title":'注册人数3',
						  "name":"app_activate_count_phone",
						  "data": "app_activate_count_phone",
						  "targets": [7],
						  "class": "center",
						  "bSortable": false,
						  "width": "1%"
					},
                    {
                        "title":'注册人数4',
                        "name":"login_count",
                        "data": "login_count",
                        "targets": [8],
                        "class": "center",
                        "bSortable": false,
                        "width": "1%"
                    },
                    {
                        "title":'注册人数5',
                        "name":"external_register_count",
                        "data": "external_register_count",
                        "targets": [9],
                        "class": "center",
                        "bSortable": false,
                        "width": "1%"
                    }
			  	],
				"sAjaxSource": ctx+"/collaborate/registerList.action?rand=" + Math.random(),
				"fnServerData": function ( sSource, aoData, fnCallback ) {//从服务器请求数据
			   			var data = $('#queryForm').serializeObject();
						
						data.aoData = JSON.stringify(aoData);
						$.ajax({
							"type": "POST",
							"dataType": 'json',
							"url": sSource,
							"data":data,
							"timeout":300000,
							"beforeSend": function() {
								// 显示loading
								showLoading();
							},
							"success": function(resp){
								console.info(resp);
								hideLoading();
								fnCallback(resp);
								initListPage();
								
							},		
							"error": function(XMLHttpRequest, textStatus, errorThrown) {
								alert('请求服务器错误,请刷新重试！！');//错误提示，包括服务器重启导致的session失效
							},			
							"complete": function () {
								hideLoading();
							}
					});
				},
				"sScrollXInner": "100%",
				"sScrollY": "100%",//如果不设置，IE会有问题
			    "aaSorting": [[2,"desc"]] //初始化加载，默认按第几列排序、排序方式（列从0开始计算）
			});
			
			
		});
	}
	 
	$('#instantStatistics').click(function () {
        $.ajax({
			type:"post",	
			async:true,
			url: ctx + "/statCommActivityRetister/instantStatistics.action?rand=" + Math.random(),
			success:function(resp){
				alert("刷新实时成功");
				query_any();
			},
			error:function(error){
				alert("刷新实时数据失败");
			}
		});
            
    });
	
	
	$(document).ready(function() {
		//时间范围插件初始化
			$('.date-picker').datepicker({
				autoclose : true,
				format : 'yyyy-mm-dd'
			});
	});
	
</script>